/**
 *  环保智库增量走势
 *  Created by dinghh on 2018/7/13.
 */
'use strict';
angular.module("MetronicApp").directive('incrementTrend', function () {
    return {
        scope: {
            id: "@",
            data: "="
        },
        restrict: 'EA',
        template: '<div style="width: 1200px;height: 500px;margin: 10px auto"></div>',
        replace: true,
        link: function ($scope, element, attrs, controller) {
            function getOption(data) {
                var option = {
                    title: {
                        text: '环保智库增量走势',
                        left:'50%',
                        top:'5%',
                        textAlign:'center',
                        textStyle:{//标题内容的样式
                            fontSize:16,//主题文字字体大小，默认为18px
                            color: '#4169E1'
                        }
                    },
                    legend: {
                        data:['产业政策库','民生经济库','能源信息库库','技术创新库','模型算法库','解决方案库','标准体系库'],
                        left:'center',
                        bottom:'1%'
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '15%',
                        containLabel: true
                    },
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,      //横坐标在刻度线下方显示
                            data : ['2018.1','2018.2','2018.3','2018.4','2018.5','2018.6']
                        }
                    ],
                    yAxis : [
                        {
                            min:0,
                            max:15000,
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            name:'产业政策库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[800, 1200, 1600, 500, 4100, 2230, 1210],
                            itemStyle:{
                                normal:{
                                    color: '#87CEFA',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        {
                            name:'民生经济库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[1356, 2316, 256, 2111, 1125, 3234, 688],
                            itemStyle:{
                                normal:{
                                    color: '#DDA0DD',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        {
                            name:'能源信息库库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[1510, 2232, 2051, 3514, 510, 330, 410],
                            itemStyle:{
                                normal:{
                                    color: '#1E90FF',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        {
                            name:'技术创新库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[320, 1932, 301, 1334, 1990, 1830, 2320],
                            itemStyle:{
                                normal:{
                                    color: '#DB7093',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        {
                            name:'模型算法库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[2820, 2932, 1901, 2934, 1670, 1020, 1580],
                            itemStyle:{
                                normal:{
                                    color: '#FF1493',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        {
                            name:'解决方案库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[920, 1232, 1301, 1934, 2290, 3330, 3320],
                            itemStyle:{
                                normal:{
                                    color: '#F0E68C',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        },
                        ,
                        {
                            name:'标准体系库',
                            type:'line',
                            stack: '总量',
                            areaStyle: {normal: {}},
                            data:[220, 1932, 101, 1934, 1290, 1330, 1320],
                            itemStyle:{
                                normal:{
                                    color: '#DC143C',          //节点颜色
                                    line:{               //线条
                                        show:false
                                    }
                                }
                            },
                            lineStyle: {
                                normal: {
                                    width: 0
                                }
                            }
                        }
                    ]
                };
                return option;
            }
            var myChart = echarts.init(document.getElementById($scope.id), 'macarons');
            myChart.setOption(getOption());

            // $scope.$watch('data', function (newVal, oldVal) {
            //     myChart.setOption(getOption(newVal));
            // });
        }
    };
});
